package equals;

import java.util.Date;
import java.util.Objects;
import java.util.GregorianCalendar;


public class Employee {

  private String name;
  private double salary;
  private Date hireDay;


  public Employee(String name, double salary, int year, int month, int day) {
    this.name = name;
    this.salary = salary;
    this.hireDay = new GregorianCalendar(year, month - 1, day).getTime();
  }


  public String getName() {
    return this.name;
  }


  public double getSalary() {
    return this.salary;
  }


  public Date getHireDay() {
    return this.hireDay;
  }


  public void raiseSalary(double percent) {
    this.salary *= (1 + percent / 100);
  }


  public boolean equals(Object otherObject) {
    if (this == otherObject)
      return true;
    if (otherObject == null)
      return false;
    if (getClass() != otherObject.getClass())
      return false;

    Employee other = (Employee) otherObject;

    return Objects.equals(name, other.name)
      && this.salary == other.salary
      && Objects.equals(this.hireDay, other.hireDay);
  }


  public int hashCode() {
    return Objects.hash(this.name, this.salary, this.hireDay);
  }


  public String toString() {
    return getClass().getName() + "[name = " + this.name + ", salary = " + this.salary + ", hire day = " + this.hireDay + "]";
  }

}
